package com.red.mybatisFirst;

import java.util.List;
import org.apache.ibatis.session.SqlSession;

import com.red.mybatisFirst.mapper.RoleMapper;
import com.red.mybatisFirst.po.Role;
import com.red.mybatisFirst.util.SqlSessionFactoryUtil;

public class Chapter4_2Main {

	public static void main(String[] args) {
		SqlSession sqlSession = null;
		try {
			sqlSession=SqlSessionFactoryUtil.openSqlSession();
			RoleMapper roleMapper=sqlSession.getMapper(RoleMapper.class);
			List<Role> list=roleMapper.findRoleByAnnotation("n", "nt");
			System.out.println("list:-->"+list);
			for (int i = 0; i < list.size(); i++) {
				System.out.println("元素："+list.get(i));
			}
			sqlSession.commit();
		} catch (Exception e) {
			e.printStackTrace();
			sqlSession.rollback();
		}finally {
			if(sqlSession!=null) {
				sqlSession.close();
			}
		}
	}

}
